#pragma once
#include <vector>
using namespace std;
#include "DAEFloat4.h"
#include "DAEFloat3.h"
#include "DAEMatrix.h"
#include "AnimationNode.h"
#include "TimedRotation.h"
class Animation;
class SkeletonNode;
#include "util.h"



typedef vector<TimedRotation>::const_iterator TRIT;
/**
* Objects of this class contain the animation for a 
* specific node. The animation data typically comes from a file.
* @author Koen Samyn
*/
class StoredAnimationNode: public AnimationNode
{
public:
	/**
	* Creates a new animation node
	*/
	StoredAnimationNode(tstring name);
	/**
	* Creates a new animation node.
	* @param name the name of the animation node.
	* @param isControlled set this to true if the bone can be affected by outside influences.
	* @param isConnectedToController set this to true if the bone is directly connected to a sensor
	* or programmatic controller.
	*/
	StoredAnimationNode(tstring name,bool isControlled,bool IsConnectedToController);
	/**
	* Destroys the Animation node.
	*/
	virtual ~StoredAnimationNode(void);
	/**
	* Adds a transform for a specific time interval.
	* @param int the time for the rotation.
	* @param rotation the rotation to add.
	* @param pivot the pivot point at this time
	*/
	void AddTransformAt(int time, DAEFloat4 rotation,DAEFloat3 pivot);
	/**
	* Adds a transform for a specific time interval.
	* @param int the time for the rotation.
	* @param rotation the rotation to add.
	* @param pivot the pivot point at this time
	*/
	void AddTransformAt(int time, DAEFloat3 rotation,DAEFloat3 pivot,DAEFloat3 scale);
	/**
	* Adds a transform for a specific time interval.
	* @param int the time for the rotation.
	* @param rotation the quaternion rotation to add.
	* @param pivot the pivot point at this time
	* @param scale the scale for the transform.
	*/
	void AddTransformAt(int time,DAEFloat4 rotation,DAEFloat3 pivot,DAEFloat3 scale);

	/**
	* Returns the rotation for this node at the specific
	* time. Time must be within the defined interval
	* for the animation.
	* @param time the time to evaluate the rotation.
	* @param rotation the quaternion with the rotation.
	* @param pivot out parameter for the translation.
	* @param scale out parameter for the scale.
	* @return true if the animation was found, false otherwise.
	*/
	const bool GetTransformAt(float time,DAEFloat4& rotation, DAEFloat3& pivot,DAEFloat3& scale) const;

	/**
	* Returns the rotation for this node at the specific time.
	* Time must be within the defined interval.
	* @param time the time to evaluate the rotation.
	* @param deltaTrans an extra transformation to apply to the original transformation.
	* @param matrix the matrix that will be set to the current world transform of the animation.
	* for the animation.
	*/
	const bool GetTransformAt(float time, DAEMatrix& deltaTrans, DAEMatrix& matrix);
	/**
	* The start of the rotations.
	*/
	TRIT TransformBegin(){return m_Rotations.begin();}
	/**
	* The end of the rotations.
	*/
	TRIT TransformEnd(){return m_Rotations.end();}
	/**
	* The number of transforms in this animation node.
	* @return the number of transforms in the animation node.
	*/
	int GetSize(){return m_Rotations.size();}
private:
	
	/**
	* The vector with quaternions.
	*/
	vector<TimedRotation> m_Rotations;
	
	/**
	* This variable controls wether the animation data is stored in an
	* animation or comes from an outside controller.
	*/
	bool m_IsControlled;
	/**
	* This variable declares wether the bone that is bound to this animation
	* node is connected to a sensor or other controller ( for example inverse kinematics)
	*/
	bool m_IsConnectedToController;
	// -------------------------
	// Disabling default copy constructor and default assignment operator.
	// If you get a linker error from one of these functions, your class is internally trying to use them. This is
	// an error in your class, these declarations are deliberately made without implementation because they should never be used.
	// -------------------------
	StoredAnimationNode(const StoredAnimationNode& t);
	StoredAnimationNode& operator=(const StoredAnimationNode& t);
};
